package com.cmc.cloud.cmclink.doc.api.document.req.so.sovo.sovslvoyvo;

import com.cmc.cloud.cmclink.doc.util.so.CompareUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;

/**
 * 订舱航次路径 Base VO，提供给添加、修改、详细的子 VO 使用
 * 如果子 VO 存在差异的字段，请不要添加到这里，影响 Swagger 文档生成
 *
 * @author codegen
 */
@Data
public class SoVslvoyBaseVO {

    @Schema(description = "外键", requiredMode = Schema.RequiredMode.REQUIRED, example = "8301")
    private Long soId;

    @Schema(description = "航程序号 第一程1，第二程2，第三程3 以此类推 中转提单，每一程都要批舱", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer routeNo;

    @Schema(description = "出口航线代码")
    @Length(max = 50, message = "{sovslvoy.lanecodeex.length}")
    private String laneCodeEx;

    @Schema(description = "船名代码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "{sovslvoy.vesselcode.notblank}")
    @Length(max = 50, message = "{sovslvoy.vesselcode.length}")
    private String vesselCode;

    @Schema(description = "出口航次", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "{sovslvoy.voyageex.notblank}")
    @Length(max = 50, message = "{sovslvoy.voyageex.length}")
    private String voyageEx;

    @Schema(description = "进口航次", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "{sovslvoy.voyageim.notblank}")
    @Length(max = 50, message = "{sovslvoy.voyageim.length}")
    private String voyageIm;

    @Schema(description = "装货港代码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "{sovslvoy.polcode.notblank}")
    @Length(max = 5, message = "{sovslvoy.polcode.length}")
    private String polCode;

    @Schema(description = "装货港码头")
    @Length(max = 9, message = "{sovslvoy.polterminal.length}")
    private String polTerminal;

    @Schema(description = "卸货港代码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "{sovslvoy.podcode.notblank}")
    @Length(max = 5, message = "{sovslvoy.podcode.length}")
    private String podCode;

    @Schema(description = "卸货港码头")
    @Length(max = 9, message = "{sovslvoy.podterminal.length}")
    private String podTerminal;

    @Schema(description = "运输类型 第一个liner   四个选项：liner、truck、train、barge", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "{sovslvoy.transmode.notblank}")
    @Length(max = 10, message = "{sovslvoy.transmode.length}")
    private String transmode;

    @Schema(description = "POL ETD 预计离港时间")
    @Length(max = 16, message = "{sovslvoy.poletd.length}")
    private String polEtd;

    @Schema(description = "POD ETA 预计到达时间")
    @Length(max = 16, message = "{sovslvoy.podeta.length}")
    private String podEta;

    @Schema(description = "指定装货点")
    @Length(max = 50, message = "{sovslvoy.stufflocex.length}")
    private String stuffLocEx;

    @Schema(description = "指定卸货堆场")
    @Length(max = 50, message = "{sovslvoy.stufflocim.length}")
    private String stuffLocIm;

    @Schema(description = "批舱状态", example = "1")
    @Length(max = 20, message = "{sovslvoy.spaceapprovestatus.length}")
    private String spaceApproveStatus;

    @Schema(description = "进入自动批舱队列标识")
    private Boolean inAutoApproveTrack;

    @Schema(description = "自动批舱已经处理过标识", requiredMode = Schema.RequiredMode.REQUIRED)
    private Boolean autoApproceProcessFlag;

    @Schema(description = "操船方")
    @Length(max = 20, message = "{sovslvoy.vesseloperator.length}")
    private String vesselOperator;

    @Schema(description = "进口航线代码")
    @Length(max = 50, message = "{sovslvoy.lanecodeim.length}")
    private String laneCodeIm;

    @Schema(description = "舱位冷插数分配id")
    private Long allocationId;

    @Schema(description = "舱位冷插数分配id 返回")
    private Long returnAllocationId;

    public String getStuffLocEx() {
        if (StringUtils.isEmpty(stuffLocEx)) {
            return null;
        }
        return stuffLocEx;
    }

    public String getStuffLocIm() {
        if (StringUtils.isEmpty(stuffLocIm)) {
            return null;
        }
        return stuffLocIm;
    }

    public void setStatusNull() {
        setSpaceApproveStatus(null);
        setAutoApproceProcessFlag(null);
        setInAutoApproveTrack(null);
        setAllocationId(null);
        setReturnAllocationId(null);
    }

    public static CompareUtils<SoVslvoyBaseVO> getMultiFieldComparator() {
        return new CompareUtils<SoVslvoyBaseVO>().comparingField(SoVslvoyBaseVO::getVesselCode)
                .thenComparing(SoVslvoyBaseVO::getTransmode)
                .thenComparing(SoVslvoyBaseVO::getVoyageEx)
                .thenComparing(SoVslvoyBaseVO::getVoyageIm)
                .thenComparing(SoVslvoyBaseVO::getPolCode)
                .thenComparing(SoVslvoyBaseVO::getPodCode)
                .thenComparing(SoVslvoyBaseVO::getLaneCodeEx)
                .thenComparing(SoVslvoyBaseVO::getLaneCodeIm)
                .thenComparing(SoVslvoyBaseVO::getStuffLocEx)
                .thenComparing(SoVslvoyBaseVO::getStuffLocIm)
                .thenComparing(SoVslvoyBaseVO::getVesselOperator);
    }

}
